package com.sptpc.getactivityresult;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class TargetActivitiy extends Activity {
    RadioGroup radioGroup;
    RadioButton save;
    RadioButton doNot;
    Intent intent = getIntent();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_target);
        radioGroup = findViewById(R.id.radio);

        save = findViewById(R.id.save);
        doNot = findViewById(R.id.donotsave);

        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.save:
                        setResult(2, null);
                        finish();
                        break;
                    case R.id.donotsave:
                        setResult(3, null);
                        finish();
                        break;
                }
            }
        });
    }
}
